package com.bwie.utils;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;

import java.util.HashMap;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/5/7 14:56
 */

public class SendMobileCodeUtil {

    public static Boolean sendMobileCode(String mobile, String message) {

        String url = "https://gyytz.market.alicloudapi.com/sms/smsSend";

        HashMap<String, Object> param = new HashMap<>();

        param.put("mobile", mobile);
        param.put("param", "**code**:"+ message + ",**minute**:5");
        param.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2");
        param.put("templateId", "908e94ccf08b4476ba6c876d13f084ad");

        //headers.put("Authorization", "APPCODE " + appcode);

        String appCode = "bd7b0a53b94a43c5aa2ffecd39cb9619";
        String body = HttpRequest.post(url)
                .header("Authorization", "APPCODE " + appCode)
                .form(param)
                .execute()
                .body();
        System.out.println("短信发送："+body);
        if(body.contains("成功")) {
            System.out.println("短信发送成功");
            return true;
        }

        System.out.println("短信发送失败");
        return false;
    }
}
